﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.GroupMember.Presenter;

namespace MINERP.GroupMember
{
    public partial class FrmHistory : Form
    {
        TaskHistoryPresenter _presenter;
        public FrmHistory()
        {
            InitializeComponent();
            _presenter = new TaskHistoryPresenter(this);
        }

        public int UserId { get; set; }

        private void FrmHistory_Load(object sender, EventArgs e)
        {
            this.Text = "完成量-----" + DateTime.Now.ToShortDateString();
            dateEdit_startTime.DateTime = DateTime.Now.Date;
            dateEdit_EndTime.DateTime = DateTime.Now.AddDays(1).Date;
        }

        internal void InitialData(DataTable _dtSource)
        {
            this.gridControl1.DataSource = _dtSource;
            barStaticItem3.Caption =_dtSource.Rows.Count.ToString();
        }

        private void dateEdit_EndTime_Closed(object sender, DevExpress.XtraEditors.Controls.ClosedEventArgs e)
        {
            //对结果进行筛选
            _presenter.FilterDs(dateEdit_startTime.DateTime, dateEdit_EndTime.DateTime);
        }

        private void dateEdit_startTime_Closed(object sender, DevExpress.XtraEditors.Controls.ClosedEventArgs e)
        {
            //对开始时间进行筛选
            _presenter.FilterDs(dateEdit_startTime.DateTime, dateEdit_EndTime.DateTime);
        }

        internal void InitialData(DataTable dtSource, int picCount, double picAreaCount)
        {
            this.gridControl1.DataSource = dtSource;
            //barStaticItem3.Caption = dtSource.Rows.Count.ToString();
            //barStaticItem6.Caption = picCount.ToString();
            //barStaticItem9.Caption = picAreaCount.ToString() + "平方米";
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //对开始时间进行筛选
            _presenter.FilterDs(dateEdit_startTime.DateTime, dateEdit_EndTime.DateTime);
        }

        private void repositoryItemHyperLinkEdit1_Click(object sender, EventArgs e)
        {
            //打开选中产品的目录
            var selectRow = gridView1.GetFocusedDataRow();
            if (selectRow!=null)
            {
               string orderPath= selectRow["orderPath"] as string;
               if (!string.IsNullOrEmpty(orderPath))
               {
                   MINERP.BLL.Common.FileBLL.OpenFoler(DataTransfer.SelectTaskInfo.OrderPath);
               }
            }
        }
    }
}
